import 'package:asmore/library.dart';
import 'package:asmore/util.dart';
import 'package:flutter/material.dart';

class WorkCard extends StatelessWidget {
  Artwork work;

  void Function() onTap;

  WorkCard({required this.work, super.key, required this.onTap});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Card.outlined(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            // 专辑封面图片
            ClipRRect(
              borderRadius: BorderRadius.only(
                topLeft: Radius.circular(12.0),
                topRight: Radius.circular(12.0),
              ),
              child: getImage(work.cover, width: 400, height: 200),
            ),
            SizedBox(height: 10.0), // 添加一些间距
            // 专辑标题和艺术家
            Container(
              padding: EdgeInsets.fromLTRB(8, 0, 0, 0),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    work.id, // 替换为你的专辑标题
                    style: Theme.of(context).textTheme.labelLarge,
                  ),
                  SizedBox(height: 5.0), // 添加一些间距
                  Text(
                    'Artist Name', // 替换为你的艺术家名字
                    style: Theme.of(context).textTheme.labelMedium,
                  ),
                  SizedBox(height: 5.0), // 添加一些间距
                  Text(
                    'tracks: ${work.tracks.length} duration: ${format(work.getDuration())}',
                    style: Theme.of(context).textTheme.labelSmall,
                  ),
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
